Transaction History


In [1]:
import pandas as pd
import oandapyV20
import oandapyV20.endpoints.transactions as trans
import configparser

In [2]:
config = configparser.ConfigParser()
config.read('../config/config_v20.ini')
accountID = config['oanda']['account_id']
access_token = config['oanda']['api_key']

In [3]:
client = oandapyV20.API(access_token=access_token)

Transaction List


In [4]:
r = trans.TransactionList(accountID)

In [5]:
client.request(r)


Out[5]:
{'count': 66,
 'from': '2017-01-20T14:23:22.308266448Z',
 'lastTransactionID': '66',
 'pageSize': 100,
 'pages': ['https://api-fxpractice.oanda.com/v3/accounts/101-003-5120068-001/transactions/idrange?from=1&to=66'],
 'to': '2017-01-28T13:31:55.464629929Z'}

Get the details of a single Account Transaction.


In [6]:
r = trans.TransactionDetails(accountID=accountID, transactionID=49)

In [7]:
client.request(r)


Out[7]:
{'lastTransactionID': '66',
 'transaction': {'accountBalance': '100000.2780',
  'accountID': '101-003-5120068-001',
  'batchID': '48',
  'financing': '0.0000',
  'id': '49',
  'instrument': 'EUR_USD',
  'orderID': '48',
  'pl': '-0.0086',
  'price': '1.06723',
  'reason': 'MARKET_ORDER_POSITION_CLOSEOUT',
  'time': '2017-01-20T16:13:56.644609335Z',
  'tradesClosed': [{'financing': '0.0000',
    'realizedPL': '-0.0086',
    'tradeID': '29',
    'units': '-100'}],
  'type': 'ORDER_FILL',
  'units': '-100',
  'userID': 5120068}}